<template>
  <div class="loupan">
    <div v-show="showList">

          <el-input type="text" class="form-control" v-model="q.name" placeholder="楼盘名称/楼盘地址" style="width: 200px"/>&emsp;


          <el-select class="form-control" v-model="q.premisesType" placeholder="请选择物业类型">
            <el-option value="">请选择物业类型</el-option>
            <el-option v-for="option in premisesTypeList" v-bind:value="option.id">
              {{ option.name}}
            </el-option>
          </el-select>&emsp;


          <el-select class="form-control" v-model="q.provinceSelected" @change="changeProvice($event)" placeholder="请选择省">
            <el-option value="">省</el-option>
            <el-option v-for="option in provinceList" :value="option.regionId"
                    v-text="option.regionName"></el-option>
          </el-select>&emsp;


          <el-select class="form-control" v-model="q.citySelected" @change="changeCity($event)" placeholder="请选择市">
            <el-option value="">市</el-option>
            <el-option v-for="option in cityList" :value="option.regionId" v-text="option.regionName"></el-option>
          </el-select>&emsp;


          <el-select class="form-control" v-model="q.countrySelected" placeholder="请选择县">
            <el-option value="">区</el-option>
            <el-option v-for="option in countryList" :value="option.regionId"
                    v-text="option.regionName"></el-option>
          </el-select>&emsp;&emsp;


          <el-button type="success" @click="query">查询</el-button>


          <!-- 				<a v-if="hasPermission('premises:premisesinfo:save')" class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a> -->
          <!-- 				<a v-if="hasPermission('premises:premisesinfo:update')" class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a> -->
          <el-button type="primary"><a  class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a></el-button>
          <el-button type="warning"><a  class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a></el-button>
          <!-- 				<a v-if="hasPermission('premises:premisesinfo:delete')" class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a> -->

      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="id"
          label="楼盘ID">
        </el-table-column>
        <el-table-column
          prop="name"
          label="楼盘名称">
        </el-table-column>
        <el-table-column
          label="楼盘图片">
          暂无图片
        </el-table-column>
        <el-table-column
          prop="address"
          label="地址">
        </el-table-column>
        <el-table-column
          prop="developer"
          label="物业管理公司">
        </el-table-column>
      </el-table>

      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="current"
        :page-sizes="sizes"
        :page-size="size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>

    <div v-show="!showList" class="panel panel-default">
      <div class="panel-heading">{{title}}</div>
      <form class="form-horizontal">
        <div class="form-group">
          <div class="col-sm-2 control-label">楼盘名称</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.name" placeholder="楼盘名称"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">省</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.province" placeholder="省"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">市</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.city" placeholder="市"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">区</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.county" placeholder="区"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">商圈</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.commercialArea" placeholder="商圈"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">地址</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.address" placeholder="地址"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">建筑面积</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.proportion" placeholder="建筑面积"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">容积率</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.grossPlotRatio" placeholder="容积率"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">绿化率</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.greenCoverage" placeholder="绿化率"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">楼栋数</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.buildingCount" placeholder="楼栋数"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">得房率</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.efficiency" placeholder="得房率"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">开发商</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.developer" placeholder="开发商"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">物业管理公司</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.estate" placeholder="物业管理公司"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">楼盘简介</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.introduce" placeholder="楼盘简介"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">社区类型</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.communityType" placeholder="社区类型"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">建筑类型</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.buildingType" placeholder="建筑类型"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label">物业类型</div>
          <div class="col-sm-10">
            <input type="text" class="form-control" v-model="premisesInfo.premisesType" placeholder="物业类型"/>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-2 control-label"></div>
          <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
          &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
import { allList, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/wishu/loupan";

export default {

  name: "Loupan",
  data(){
    return {
      tableData:[],
      current:1,
      sizes:[2,3,5,10],
      size:5,
      total:0,
      publishTypeList: '',
      premisesTypeList: '',
      provinceList: '省',		// 省
      cityList: '市',        // 市
      countryList: '区',     // 区
      q: {
        name: '',
        publishType: '',
        premisesType: '',
        provinceSelected: '',
        citySelected: '',
        countrySelected: '',
      },
      showList: true,
      title: null,
      premisesInfo: {}
    }
  },
  created:function(){
    this.initSelect();
    this.iniProvince();
  },
  methods: {
    iniProvince () {
      this.getRegionList(1, 0);
    },
    getRegionList () {
      allList(this.current,this.size,this.q).then((res)=>{
        console.log(res)
        this.tableData=res.records;
        this.total=res.total;
        //this.tableData=res.data.records[0][0];
        //this.total=res.data.total;
        /*if (res.data.code === 0) {
          if (regionCode === 0) {// 0 初始化省份  1选择省份获取省下城市  2选择城市获取城市下县（区）
            this.provinceList = res.data.list;
          } else if (regionCode === 1) {
            this.cityList = res.data.list;
          } else if (regionCode === 2) {
            this.countryList = res.data.list;
          }
        } else {
          alert(res.data.msg);
        }*/
      })
      /*$.ajax({
        type: "POST",
        url: baseURL + "sys/region/regionList",
        data: {"parentId": parentId},
        success: function (r) {
          if (r.code === 0) {
            if (regionCode === 0) {// 0 初始化省份  1选择省份获取省下城市  2选择城市获取城市下县（区）
              vm.provinceList = r.list;
            } else if (regionCode === 1) {
              vm.cityList = r.list;
            } else if (regionCode === 2) {
              vm.countryList = r.list;
            }
          } else {
            alert(r.msg);
          }
        }
      });*/
    },
    changeProvice: function (event) {
      /*var parentId = event.target.value;
      this.cityList = '';
      this.countryList = '';
      this.q.citySelected = '';
      this.q.countrySelected = '';
      this.getRegionList(parentId, 1);*/
    },
    changeCity: function (event) {
      /*this.countryList = '';
      this.q.countrySelected = '';
      var parentId = event.target.value;
      this.getRegionList(parentId, 2);*/
    },
    initSelect(){
      /*this.loading = true;
      listLoupan(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );*/
    },
    query: function () {
       this.getRegionList();
    },
    add: function(){
      //window.location.href= localUrl +"modules/permanent/premises/premisesinfo.html";
    },
    update: function (event) {
      /*var id = getSelectedRow();
      if(id == null){
        return ;
      }
      window.location.href= localUrl +"modules/permanent/premises/premisesinfo.html?id="+id;*/
    },
    saveOrUpdate: function (event) {
      /*var url = this.premisesInfo.id == null ? "premises/premisesinfo/save" : "premises/premisesinfo/update";
      $.ajax({
        type: "POST",
        url: baseURL + url,
        contentType: "application/json",
        data: JSON.stringify(vm.premisesInfo),
        success: function(r){
          if(r.code === 0){
            alert('操作成功', function(index){
              this.reload();
            });
          }else{
            alert(r.msg);
          }
        }
      });*/
    },
    del: function (event) {
      /*var ids = getSelectedRows();
      if(ids == null){
        return ;
      }

      confirm('确定要删除选中的记录？', function(){
        $.ajax({
          type: "POST",
          url: baseURL + "premises/premisesinfo/delete",
          contentType: "application/json",
          data: JSON.stringify(ids),
          success: function(r){
            if(r.code == 0){
              alert('操作成功', function(index){
                $("#jqGrid").trigger("reloadGrid");
              });
            }else{
              alert(r.msg);
            }
          }
        });
      });*/
    },
    getInfo: function(id){
      /*$.get(baseURL + "premises/premisesinfo/info/"+id, function(r){
        this.premisesInfo = r.premisesInfo;
      });*/
    },
    reload: function (event) {
      /*this.showList = true;
      var page = 1;
      $("#jqGrid").jqGrid('setGridParam',{
        postData:this.q,
        page:page
      }).trigger("reloadGrid");*/
    },
    handleSizeChange(val) {
      this.size=val;
      this.getRegionList();
    },
    handleCurrentChange(val) {
      this.current=val;
      this.getRegionList();
    }
  }
}
</script>

<style scoped>

</style>
